#ifndef SHA256_H
#define SHA256_H

/*************************** HEADER FILES ***************************/
#include <stddef.h>
#include "ddclconfig.h"

/****************************** MACROS ******************************/
#define DDCL_SHA2_DIGEST_SIZE 32            // SHA256 outputs a 32 byte digest
#define DDCL_SHA2_STRING_SIZE 65

/**************************** DATA TYPES ****************************/
// typedef unsigned char dduint8;             // 8-bit byte
// typedef unsigned int  DDCL_SHA2dduint32;             // 32-bit word, change to "long" for 16-bit machines

typedef struct {
	dduint8 data[64];  // current 512-bit chunk of message data, just like a buffer
	dduint32 datalen;   // sign the data length of current chunk
	unsigned long long bitlen;  // the bit length of the total message
	dduint32 state[8];  // store the middle state of hash abstract
} ddcl_SHA2Ctx;

/*********************** FUNCTION DECLARATIONS **********************/
DDCLAPI void
ddcl_init_sha2(ddcl_SHA2Ctx *ctx);
DDCLAPI void
ddcl_update_sha2(ddcl_SHA2Ctx *ctx, const dduint8 data[], size_t len);
DDCLAPI void
ddcl_final_sha2(ddcl_SHA2Ctx *ctx, dduint8 hash[]);
DDCLAPI void
ddcl_tostring_sha2 (
        const dduint8 digest[DDCL_SHA2_DIGEST_SIZE],
        dduint8 str[DDCL_SHA2_STRING_SIZE]);

#endif   // SHA256_H
